<%var jstpl = {%>
<script>
	var app = new Vue({
		el: "#gexin_body",
		data: {
			query: {
				log_info: "",
				log_level: "",
				startdate: "",
				enddate: "",
				pageNumber: 1,
				pageSize: 10
			},
			data_result: {}
		},
		created: function() {
			this.loadPage("init")
		},
		methods: {
			loadPage: function(model) { //载入模式有两种  init初始化载入 load分页载入
				if(model == "init") {
					this.query.pageNumber = 1;
				}
				Ajax("/system/core/log/query", this.query, function(d) {
					app.data_result = d;
					if(d.firstPage == true) {
						layui.laypage.render({
							elem: 'gexin_page', //注意，这里的 test1 是 ID，不用加 # 号
							layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
							count: d.totalRow, //数据总数，从服务端得到
							limit: app.query.pageSize,
							jump: function(obj, first) {
								app.query.pageNumber = obj.curr;
								if(app.query.pageSize != obj.limit) {
									app.query.pageSize = obj.limit;
									app.loadPage("init");
									return;
								}
								if(!first) {
									app.loadPage("load");
								}
							}
						});
					}
				})
			},
			outExcel: function() {
				window.location.href = "/system/core/log/out_excel?data=" + JSON.stringify(this.query);
				return true;
			}
		}
	})

	$(document).ready(function() {
		//下面是日期回调  
		var laydate = layui.laydate;
		laydate.render({
			elem: "#start",
			type: "datetime",
			done: function(value, date, endDate) {
				app.query.startdate = value;
			}
		});
		laydate.render({
			elem: "#end",
			type: "datetime",
			done: function(value, date, endDate) {
				app.query.enddate = value;
			}
		});

		if("${log_level!}" != '') {
			app.query.log_level = "${log_level!}";
			app.loadPage("init");
		}
		$("#tbody_body").on("click",".view_log_data",function(){
			var data  = $(this).data("log_data");
			layer.tips(data, this, {
			  tips: [1, '#78BA32']
			});
		})

	})
</script>
<%};%>
<%var csstpl = {%>
<style type="text/css">
	[v-cloak] {
		display: none
	}
	.view_log_data {
		font-size: 12px;
		color: #1E9FFF;
	}
</style>
<%};%>
<%layout("../layout/_layout_layui.html",{title:'日志管理',jstpl:jstpl,csstpl:csstpl}){ %>
<div class="layui-row" v-cloak>
	<div class="layui-col-md12">
		<div class="layui-col-md6">
			<div class="layui-form-item ">
				<label class="layui-form-label">描述信息</label>
				<div class="layui-input-block">
					<input type="text" name="title" v-model="query.log_info" required placeholder="请输入描述信息" autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>

		<div class="layui-col-md6">
			<div class="layui-form-item">
				<label class="layui-form-label">类型</label>
				<div class="layui-input-block">
					<#dict_select attr='name="log.log_level"  class="layui-input" v-model="query.log_level"' key="LOG_TYPE" />
				</div>
			</div>
		</div>

		<div class="layui-col-md12">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label ">时间范围</label>
					<div class="layui-input-inline">
						<input type="text" name="price_min" v-model="query.startdate" id="start" placeholder="开始时间" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid">到</div>
					<div class="layui-input-inline">
						<input type="text" name="price_max" v-model="query.enddate" id="end" placeholder="结束时间" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-input-inline">
						<button type="button" @click="loadPage('init')" class="layui-btn layui-btn-normal">查询</button>
						<button type="button" @click="outExcel()" class="layui-btn layui-btn-info">导出excel</button>
					</div>
				</div>
			</div>
		</div>

	</div>

	<div class="layui-col-md12" style="margin-top: 20px">
		<table class="layui-table">
			<thead>
				<tr>
					<th>ID</th>
					<th>触发时间</th>
					<th>用户名</th>
					<th>级别</th>
					<th>描述信息</th>

				</tr>
			</thead>
			<tbody id="tbody_body">
				<tr v-for="d  in  data_result.list">
					<td>{{d.id}}</td>
					<td>{{d.createtime}}</td>
					<td>{{d.username}}-{{d.user_relName}}</td>
					<td>
						<span class="layui-badge layui-bg-orange">{{d.log_type_text}}</span>
						<a href="#" v-if="d.log_data!=null" class="view_log_data" :data-log_data="d.log_data">查看数据</a>
					</td>
					<td>{{d.log_info}}
					</td>
				</tr>
				<tr v-if="data_result.list==0">
					<td colspan="5" style="text-align:center;height:300px">
						<h1>没有数据</h1></td>
				</tr>
			</tbody>
		</table>
		<fieldset id="gexin_page" class="layui-elem-field layui-field-title">
		</fieldset>
	</div>
</div>
<%};%>